import hashlib

def pwned(password):
    password = hashlib.sha1(password).hexdigest().upper()
    with open("pwned-passwords-sha1-ordered-by-count-v4.txt", "r") as data:

        for element in data:
            if password == element[0:len(password)]:
                return True
            

    data.close()





usr_input = input("Enter your password to check if it is part of the HIBP collection: ")

if pwned(usr_input.encode()):
    print("Your password seems to be compromised!")

else:
    print("Your password does not match any hash value in this collection.")
    print("Keep in mind that this is no guarantee that your password is safe.")


